/*
============================================================================
 Name        : BlockMemo.h
 Author      : \x{738b}\x{658c}
 Version     :
 Copyright   : \x{76ca}\x{76df}\x{8f6f}\x{4ef6}
 Description : CBlockMemo declaration
============================================================================
*/

#ifndef BlockMemo_H
#define BlockMemo_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include "Block.h"
#include "SMSEngine.h"
#ifdef __SERIES60_3X__
#include "PhoneCallMaker2.h"
#else
#include "PhoneCallMaker.h"
#endif
#include "Flickable.h"
// CLASS DECLARATION

/**
*  CBlockMemo
* 
*/
class CBlockMemo : public CBlock,
	public MSmsEngineObserver,
	public MAnsPhoneCallMakerObserver,
	public MFlickableCallback
{
public:
	~CBlockMemo();

	static CBlockMemo* NewL(CBaseBlock* bsBack, const TInt& nType, const TDesC& strText);

	static CBlockMemo* NewLC(CBaseBlock* bsBack, const TInt& nType, const TDesC& strText);

	CBlockMemo(CBaseBlock* bsBack, const TInt& nType, const TDesC& strText);

public:
	/**
	* From MSmsEngineObserver
	*/
	void SendingMessage();
	void MessageSent();
	void MessageReceived(const TDesC& addr, const TDesC& msg);
	void SmsEngineInitialized();
	void SmsEngineError(TInt aErrorCode);
	void MessageDeleted(); //if automatic deletion is on
	
public:
	// from MFlickableCallback
	virtual TPoint ScrollOffset() const;

	virtual void SetScrollOffset(const TPoint& aOffset);

public:
	void HandleCallHungUpL();

	void MakeCall();

	void SendRegSMS();
	void SetMemoInfo(const TInt& aResID);
	void SetMemoInfo(const TDesC& aDes);

	void SetOperation(const TInt16& sOperType,const TDesC& strTel);

private:
	void ConstructL(const TDesC& strText);

public:
	//from CBlock
	void OnDraw(CFbsBitGc& g) const;

	void DrawOneSecond(CFbsBitGc& g) const;

	void OnKeyDown(TInt keyCode);
	
	void ChangeScrollPos(TInt nPos);

	TBool MustLogin();

	void WriteData(TDes8& aBuf);

	TBool ReadData(const TDesC8& aData);
	
	TInt GetIOType();

	TInt GetDataLength();

	TInt16 GetDataType();
	
	void SizeChanged();
	
	void OnMouseDown(const TPoint& aPt);

	void OnMouseMove(const TPoint& aPt);

	void OnMouseUp(const TPoint& aPt);

protected:
	void BeforeDraw(CFbsBitGc& g) const;

public:
	//new functions
	static void BrowseWAPPageL(const TDesC& aAddr);

private:
	TInt m_nBlockMemoType;
	CDesCArray* m_vText;
	HBufC* 	m_strText;
	TInt m_nStart;
	CSmsEngine* iSmsEngine;
	TBool		m_bSending;
	HBufC* iUpdateUrl;
	TBool iNeedToUpdate;
	
#ifdef __SERIES60_3X__
	CPhoneCallMaker2*	m_CallMaker;
#else
	CPhoneCallMaker*	m_CallMaker;
#endif

public:
	TInt m_nSubType;
	TInt16 m_sOperation;
	TBuf<32> m_strOperTel;
	
	TInt iOffset;
	TInt iHeight;
	CFlickable* iFlickable;
	TRect iListRect;

	mutable TInt iStartItem;
	mutable TInt iEndItem;
};

#endif // BlockMemo_H
